<?php
ob_start(); // 开启输出缓冲
// 先输出 HTML 或其他内容
?>
<?php
    //登陆
	error_reporting(0);//关闭提示
	$yonghuming = $_POST['yonghuming'];
	$mima = $_POST['mima'];
	// echo "<script> alert(".$yonghuming.$mima."); </script>";
	if($yonghuming!=NULL and $mima!=NULL)
	{
		//链接数据库
		require_once('./config.php');
		$con=login();
		if (!$con)
		{
			die('MYSQL链接失败: ' . mysqli_error());
		}
		else
		{
			$sql="SELECT tequan,QQ FROM user WHERE tequan='admin' and 用户名='$yonghuming' and 密码='$mima'";//查询内容
			$cxnr = mysqli_query($con,$sql);
			$row = mysqli_fetch_array($cxnr);
			if (mysqli_num_rows($cxnr) > 0)
			{
				setcookie('jdQQ',$row['QQ'],time()+3600*24,'/');
				setcookie('jduser',$yonghuming,time()+3600*24,'/');
				setcookie('jdpassword',$mima,time()+3600*24,'/');
				echo '<script> alert("已登录，管理员！"); </script>';
				header('Location: PCmain.php');
			}
			else
			{
				$sql="SELECT 用户名,密码,QQ FROM user WHERE 用户名 ='$yonghuming' and 密码='$mima'";//查询内容
				$cxnr = mysqli_query($con,$sql);
				$row = mysqli_fetch_array($cxnr);
				if (mysqli_num_rows($cxnr) > 0)
				{
					setcookie("jdQQ",$row['QQ'],time()+3600*24);
					setcookie("jduser",$yonghuming,time()+3600*24);
					setcookie("jdpassword",$mima,time()+3600*24);
					echo '<script> alert("已登录，基础账户！"); </script>';
					header('Location: PCmain.php');
				}
				elseif($s==1 and ($yonghuming==NULL or $mima==NULL))
				{
					echo '<script> alert("查询失败,请检查你输入的内容"); </script>';
				}
			}	
		}
	}
	else{
		echo '<script> alert("请输入内容"); </script>';
	}
?>
